package com.hualan.service;

import com.hualan.domain.UserCourse;
import com.hualan.mapper.UserCourseMapper;
import com.hualan.util.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UserCourseService {
    @Autowired
    private UserCourseMapper userCourseMapper;

    //根据状态查询用户的课程
    public R selectByStatus(int status){
        List<UserCourse> list=userCourseMapper.selectAllByStatus(status);
        if (list==null){
            return R.fail(500);
        }else {
            return R.success(list);
        }
    }
    //  通过用户id查询用户所有的课程id,再通过课程id联表查询课程
    public R selectAll(int userId , int status){
        List<UserCourse> list=userCourseMapper.selectAll(userId,status);
        if (list==null){
            return R.fail(500);
        }else {
            return R.success(list);
        }
    }
}
